package com.dd.census.controller;

import com.dd.census.controller.common.BaseController;
import com.dd.census.service.impl.DashboardServiceImpl;
import com.dd.census.tools.SysException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.servlet.http.HttpServletRequest;

@Controller
@RequestMapping(value = "rest/dashboar")
public class DashboardController extends BaseController {

    private static final Logger logger = LoggerFactory.getLogger(DashboardController.class);

    @Autowired
    DashboardServiceImpl dashboardService;

    @RequestMapping("selectDashboar")
    public ResponseEntity<Object> selectDashboar(String userId, HttpServletRequest request) {
        try {
            return this.doSuccess(request, dashboardService.selectDashboar(userId));

        } catch (SysException e) {
            // 业务异常
            return doFaild(request, e);

        } catch (Exception e) {
            // 系统异常
            logger.error("Internal Server Error", e);
            return doFaild(request, HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
}